<?php

class Product_m extends CI_Model {

    //put your code here
    public function __construct() {
        parent::__construct();
        $this->load->database();
    }

    function get_all_products($lang=1) {
        $data = FALSE;
        try {
            $data = $this->db->select('es_product.id,es_product.id_category_default,
                es_image.file_name,es_product.quantity,
                es_product.price, es_product_lang.`name`,users.username')
                            ->from('es_product,es_product_lang,users,es_image')
                            ->where('es_product.id = es_product_lang.id_product')
                            ->where('es_product.default_image = es_image.id')
                            ->where('es_product.id_owner = users.id')
                            ->where('es_product_lang.id_lang', $lang)
                            ->get()->result_array();
            return $data;
        } catch (Exception $exc) {
            return FALSE;
        }
    }

}
